/*
 * @(#)AssociationSourceAndTargetURNFilter.java
 * Date 2013-09-30
 * Version 1.0
 * Author Jim Horner
 * Copyright (c)2012
 */


package us.hornerscorners.lamppost.registry.query;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;

import us.hornerscorners.lamppost.model.IFilter;

import us.hornerscorners.lamppost.model.document.Association;


/**
 * Class description
 *
 *
 * @version        v1.0, 2013-09-30
 * @author         Jim Horner    
 */
public class AssociationSourceAndTargetURNFilter implements IFilter<Association> {

    /** Field description */
    private final List<String> urns;

    /**
     * Constructs ...
     *
     */
    private AssociationSourceAndTargetURNFilter() {

        super();
        this.urns = new ArrayList<>();
    }

    /**
     * Constructs ...
     *
     *
     * @param urns
     */
    public AssociationSourceAndTargetURNFilter(Collection<String> urns) {

        this();
        this.urns.addAll(urns);
    }

    /**
     * Constructs ...
     *
     *
     * @param urn
     */
    public AssociationSourceAndTargetURNFilter(String... urn) {

        this();
        this.urns.addAll(Arrays.asList(urn));
    }

    /**
     * Method description
     *
     *
     * @param item
     *
     * @return
     */
    @Override
    public boolean accept(Association item) {

        return (this.urns.contains(item.getSourceEntryURN())
                && this.urns.contains(item.getTargetEntryURN()));
    }
}
